package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.AccountBindRoleInfo;
import cc.mrbird.febs.power.service.IAccountBindRoleInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/account-bind-role-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AccountBindRoleInfoController {

    private final IAccountBindRoleInfoService iAccountBindRoleInfoService;

    /**
     * 根据账户获取绑定的角色
     * @param accountId
     * @return
     */
    @GetMapping("info/{accountId}")
    public R getRoleInfoByAccount(@PathVariable("accountId") Integer accountId) {
        return R.ok(iAccountBindRoleInfoService.getRoleInfoByAccount(accountId));
    }

    /**
     * 新增账户ID绑定角色ID
     * @param accountBindRoleInfo
     * @return
     */
    @PostMapping("/AccountBindRoleAdd")
    public R AccountBindRoleAdd(AccountBindRoleInfo accountBindRoleInfo) {
        return R.ok(iAccountBindRoleInfoService.save(accountBindRoleInfo));
    }

    /**
     * 修改账户ID绑定角色ID
     * @param accountBindRoleInfo
     * @return
     */
    @PutMapping("/AccountBindRoleEdit")
    public R AccountBindRoleEdit(AccountBindRoleInfo accountBindRoleInfo) {
        return R.ok(iAccountBindRoleInfoService.updateById(accountBindRoleInfo));
    }

    /**
     * 根据ID删除记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R AccountBindRoleDel(@PathVariable Integer id) {
        return R.ok(iAccountBindRoleInfoService.removeById(id));
    }

}
